package com.jia.leetCode;

/**
 * @program: Leetcode
 * @description:
 * @author: STU756
 * @create: 2020-08-09 15:21
 */
public class Pro5469 {
    public boolean canConvertString(String s, String t, int k) {
        if(s.length()!=t.length())return false;
        int []a=new int[26];
        int x;
        for(int i=0;i<s.length();i++){
            x=t.charAt(i)-s.charAt(i);//计算转化次数
            if(x<0)x+=26;//模26
            a[x]++;
        }
        x=0;
        int idx=0;
        for(int i=1;i<a.length;i++){//求a[x]的最大值及其下标
            if(a[i]>=x){//注意等号
                x=a[i];
                idx=i;
            }
        }
        return 26*(x-1)+idx<=k;//计算最小操作次数并和k比较
    }


    public static void main(String[] args) {
        Pro5469 pro5469 = new Pro5469();
        System.out.println(pro5469.canConvertString("input", "ouput", 9));
    }
}
